package com.twu.biblioteca;


import java.util.ArrayList;

public class Menu {
    public ArrayList<Option> options;

    public Menu(ArrayList<Option> options){
        this.options = options;
    }

    public String outMenu(boolean isLogged){
        String newLine = System.getProperty("line.separator");
        String output = newLine + "== MENU ==" + newLine;
        for(int i=0; i < options.size(); i++){
            Option option = options.get(i);
            String strOption = "[ "+ option.getId() +" ]" + option.getName();

            if (!isLogged && option.identical(Option.USER_LOGIN)){
                output += strOption;
            } else {
                if (isLogged && option.identical(Option.USER_LOGOUT)) {
                    output += strOption;
                } else {
                    if(!option.identical(Option.USER_LOGOUT) && !option.identical(Option.USER_LOGIN)){
                        output += strOption;
                    }
                }
            }

            output += newLine;
        }
        return output;
    }

    public boolean validateOption(Option option){
        if (this.options.contains(option)){
            return true;
        }
        else {
            return false;
        }
    }
}
